/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  @endpointMap = {
    'ap-southeast-1' = 'dysmsapi.ap-southeast-1.aliyuncs.com',
    'ap-southeast-5' = 'dysmsapi.ap-southeast-5.aliyuncs.com',
    'cn-beijing' = 'dysmsapi-proxy.cn-beijing.aliyuncs.com',
    'cn-hongkong' = 'dysmsapi-xman.cn-hongkong.aliyuncs.com',
    'eu-central-1' = 'dysmsapi.eu-central-1.aliyuncs.com',
    'us-east-1' = 'dysmsapi.us-east-1.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('dysmsapi', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model BatchSendMessageToGlobeRequest {
  channelId?: string(name='ChannelId', example='sms-djnfjn344'),
  from?: string(name='From', description='The mobile phone number of the sender. You can also specify a sender ID. The sender ID can contain both letters and digits. If it does, the ID must be between 1 to 11 characters in length. If the sender ID contains only digits, it must be 1 to 15 characters in length.', example='Alicloud321'),
  message?: string(name='Message', description='The content of the message.

This parameter is required.', example='[\\\\"message to 931520581****\\\\",\\\\"message to 931530581****\\\\",\\\\"message to 931540581****\\\\",\\\\"message to 931550581****\\\\"]'),
  taskId?: string(name='TaskId', description='The ID of the messaging campaign. It must be 1 to 255 characters in length. The ID is the value of the TaskId field in the delivery receipt of the message.', example='123789****'),
  to?: string(name='To', description='The mobile phone numbers to which the message is sent. You must add the dialing code to the beginning of each mobile phone number.

For more information, see [Dialing codes](https://www.alibabacloud.com/help/en/short-message-service/latest/dialing-codes).

This parameter is required.', example='[\\\\"931520581****\\\\",\\\\"931530581****\\\\",\\\\"931540581****\\\\",\\\\"931550581****\\\\"]'),
  type?: string(name='Type', description='The type of the message. Valid values:

*   **NOTIFY**: notification
*   **MKT**: promotional message', example='NOTIFY'),
  validityPeriod?: long(name='ValidityPeriod', description='The validity period of the message. Unit: seconds.', example='1'),
}

model BatchSendMessageToGlobeResponseBody = {
  failedList?: string(name='FailedList', description='The list of mobile phone numbers that failed to receive the message.', example='["931520581****","931530581****"]'),
  from?: string(name='From', description='The sender ID returned.', example='Alicloud321'),
  messageIdList?: string(name='MessageIdList', description='The ID of the message.', example='["123****","124****"]'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8D28D3'),
  responseCode?: string(name='ResponseCode', description='The status code. If OK is returned, the request is successful. For more information, see [Error codes](https://www.alibabacloud.com/help/en/short-message-service/latest/error-codes).', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the status code.', example='The SMS Send Request was accepted'),
  successCount?: string(name='SuccessCount', description='The number of mobile phone numbers that received the message.', example='2'),
}

model BatchSendMessageToGlobeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: BatchSendMessageToGlobeResponseBody(name='body'),
}

/**
 * @summary Sends a message to multiple recipients in countries or regions outside the Chinese mainland.
 *
 * @description *   You cannot call the BatchSendMessageToGlobe operation to send messages to the Chinese mainland.
 * *   You can call the BatchSendMessageToGlobe operation to send notifications and promotional messages to a limited number of mobile phone numbers at a time. To send messages to a large number of mobile phone numbers at a time, use the mass messaging feature in the SMS console.
 * *   For time-sensitive related messages, we recommend that you use the [SendMessageToGlobe](https://www.alibabacloud.com/help/en/sms/developer-reference/api-dysmsapi-2018-05-01-batchsendmessagetoglobe) operation to ensure that messages are delivered on time.
 * *   In each request, you can send messages to up to 1,000 mobile phone numbers.
 * ### [](#qps-)QPS limit
 * You can call this operation only once per second. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
 *
 * @param request BatchSendMessageToGlobeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return BatchSendMessageToGlobeResponse
 */
async function batchSendMessageToGlobeWithOptions(request: BatchSendMessageToGlobeRequest, runtime: Util.RuntimeOptions): BatchSendMessageToGlobeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.channelId)) {
    query['ChannelId'] = request.channelId;
  }
  if (!Util.isUnset(request.from)) {
    query['From'] = request.from;
  }
  if (!Util.isUnset(request.message)) {
    query['Message'] = request.message;
  }
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  if (!Util.isUnset(request.type)) {
    query['Type'] = request.type;
  }
  if (!Util.isUnset(request.validityPeriod)) {
    query['ValidityPeriod'] = request.validityPeriod;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'BatchSendMessageToGlobe',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Sends a message to multiple recipients in countries or regions outside the Chinese mainland.
 *
 * @description *   You cannot call the BatchSendMessageToGlobe operation to send messages to the Chinese mainland.
 * *   You can call the BatchSendMessageToGlobe operation to send notifications and promotional messages to a limited number of mobile phone numbers at a time. To send messages to a large number of mobile phone numbers at a time, use the mass messaging feature in the SMS console.
 * *   For time-sensitive related messages, we recommend that you use the [SendMessageToGlobe](https://www.alibabacloud.com/help/en/sms/developer-reference/api-dysmsapi-2018-05-01-batchsendmessagetoglobe) operation to ensure that messages are delivered on time.
 * *   In each request, you can send messages to up to 1,000 mobile phone numbers.
 * ### [](#qps-)QPS limit
 * You can call this operation only once per second. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
 *
 * @param request BatchSendMessageToGlobeRequest
 * @return BatchSendMessageToGlobeResponse
 */
async function batchSendMessageToGlobe(request: BatchSendMessageToGlobeRequest): BatchSendMessageToGlobeResponse {
  var runtime = new Util.RuntimeOptions{};
  return batchSendMessageToGlobeWithOptions(request, runtime);
}

model ConversionDataRequest {
  conversionRate?: string(name='ConversionRate', description='Conversion rate monitoring return value.

>  The value of this parameter is of type double, and the value is between [0,1].

This parameter is required.', example='0.53'),
  reportTime?: long(name='ReportTime', description='Timestamp of the conversion rate observation should be a Unix timestamp, a millisecond-level long integer.

>  If this field is not specified: the current timestamp is the default.', example='1349055900000'),
}

model ConversionDataResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8D****'),
  responseCode?: string(name='ResponseCode', description='Status code. Returning OK means the request was successful. For other error codes, please refer to the [Error codes](https://help.aliyun.com/document_detail/180674.html) list.', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the status code.', example='OK'),
}

model ConversionDataResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConversionDataResponseBody(name='body'),
}

/**
 * @summary This API, sends conversion data to the Alibaba SMS service.
 *
 * @description Metrics:
 * *   Requested OTP messages
 * *   Verified OTP messages
 * An OTP conversion rate is calculated based on the following formula: OTP conversion rate = Number of verified OTP messages/Number of requested OTP messages.
 *
 * @param request ConversionDataRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConversionDataResponse
 */
async function conversionDataWithOptions(request: ConversionDataRequest, runtime: Util.RuntimeOptions): ConversionDataResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.conversionRate)) {
    body['ConversionRate'] = request.conversionRate;
  }
  if (!Util.isUnset(request.reportTime)) {
    body['ReportTime'] = request.reportTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConversionData',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This API, sends conversion data to the Alibaba SMS service.
 *
 * @description Metrics:
 * *   Requested OTP messages
 * *   Verified OTP messages
 * An OTP conversion rate is calculated based on the following formula: OTP conversion rate = Number of verified OTP messages/Number of requested OTP messages.
 *
 * @param request ConversionDataRequest
 * @return ConversionDataResponse
 */
async function conversionData(request: ConversionDataRequest): ConversionDataResponse {
  var runtime = new Util.RuntimeOptions{};
  return conversionDataWithOptions(request, runtime);
}

model QueryMessageRequest {
  messageId?: string(name='MessageId', description='The ID of the message.

This parameter is required.', example='1008030xxx3003'),
}

model QueryMessageResponseBody = {
  errorCode?: string(name='ErrorCode', description='The status code of the message.', example='DELIVERED'),
  errorDescription?: string(name='ErrorDescription', description='The description of the status code.', example='success'),
  message?: string(name='Message', description='The content of the message.', example='Hello!'),
  messageId?: string(name='MessageId', description='The ID of the message.', example='1008030xxx3003'),
  numberDetail?: {
    carrier?: string(name='Carrier', description='The carrier that owns the mobile phone number.', example='CMI'),
    country?: string(name='Country', description='The country to which the mobile phone number belongs.', example='China'),
    region?: string(name='Region', description='The region to which the mobile phone number belongs.', example='HongKong'),
  }(name='NumberDetail', description='The details about the mobile phone number.'),
  receiveDate?: string(name='ReceiveDate', description='The time when the delivery receipt was received from the carrier.', example='Mon, 24 Dec 2018 16:58:22 +0800'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8D28D0'),
  responseCode?: string(name='ResponseCode', description='The status code of the delivery request.', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the delivery request status.', example='The SMS Send Request was accepted'),
  sendDate?: string(name='SendDate', description='The time when the message was sent to the carrier.', example='Mon, 24 Dec 2018 16:58:22 +0800'),
  status?: string(name='Status', description='The delivery status of the message.

*   1: The message was sent.
*   2: The message failed to be sent.
*   3: The message is being sent.', example='1'),
  to?: string(name='To', description='The mobile phone number to which the message was sent.', example='6581xxx810'),
}

model QueryMessageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: QueryMessageResponseBody(name='body'),
}

/**
 * @summary Queries the delivery report of a message.
 *
 * @description ### QPS limit
 * You can call this operation up to 300 times per second. If the number of the calls per second exceeds a limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limits when you call this operation.
 *
 * @param request QueryMessageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return QueryMessageResponse
 */
async function queryMessageWithOptions(request: QueryMessageRequest, runtime: Util.RuntimeOptions): QueryMessageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.messageId)) {
    query['MessageId'] = request.messageId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryMessage',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the delivery report of a message.
 *
 * @description ### QPS limit
 * You can call this operation up to 300 times per second. If the number of the calls per second exceeds a limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limits when you call this operation.
 *
 * @param request QueryMessageRequest
 * @return QueryMessageResponse
 */
async function queryMessage(request: QueryMessageRequest): QueryMessageResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryMessageWithOptions(request, runtime);
}

model SendMessageToGlobeRequest {
  channelId?: string(name='ChannelId', description='The ID of the channel.', example='3790'),
  from?: string(name='From', description='The mobile phone number of the sender. You can also specify a sender ID. The sender ID can contain both letters and digits. If it does, the ID must be between 1 to 11 characters in length. If the sender ID contains only digits, it must be 1 to 15 characters in length.', example='Alicloud321'),
  message?: string(name='Message', description='The content of the message.

This parameter is required.', example='Hello'),
  taskId?: string(name='TaskId', description='The ID of the messaging campaign. It must be 1 to 255 characters in length. The ID is the value of the TaskId field in the delivery receipt of the message.', example='123****789'),
  to?: string(name='To', description='The mobile phone number to which the message is sent. You must add the dialing code to the beginning of the mobile phone number. Example: 8521245567\\\\*\\\\*\\\\*\\\\*.

For more information, see [Dialing codes](https://www.alibabacloud.com/help/en/sms/product-overview/dialing-codes?spm=a2c63.p38356.0.0.48b940a1PFYRMz).

>  You cannot call the SendMessageToGlobe operation to send messages to the Chinese mainland.

This parameter is required.', example='8521245567****'),
  validityPeriod?: long(name='ValidityPeriod', description='The validity period of the message. Unit: seconds.', example='600'),
}

model SendMessageToGlobeResponseBody = {
  from?: string(name='From', description='The sender ID returned.', example='Alicloud321'),
  messageId?: string(name='MessageId', description='The ID of the message.', example='1008030300****'),
  numberDetail?: {
    carrier?: string(name='Carrier', description='The carrier that owns the mobile phone number.', example='CMI'),
    country?: string(name='Country', description='The country to which the mobile phone number belongs.', example='China'),
    region?: string(name='Region', description='The region to which the mobile phone number belongs.', example='HongKong'),
  }(name='NumberDetail', description='The details about the mobile phone number of the recipient.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8DE990'),
  responseCode?: string(name='ResponseCode', description='The status code of the delivery request.', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the delivery request status.', example='The SMS Send Request was accepted'),
  segments?: string(name='Segments', description='The number of messages that incurred fees.', example='1'),
  to?: string(name='To', description='The mobile phone number to which the message was sent.', example='1380000****'),
}

model SendMessageToGlobeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SendMessageToGlobeResponseBody(name='body'),
}

/**
 * @summary Sends a message to regions outside the Chinese mainland.
 *
 * @description ### [](#)Usage notes
 * The SendMessageToGlobe API operation does not support message delivery to the Chinese mainland.
 * ### [](#qps-)QPS limit
 * You can call this operation up to 30 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
 *
 * @param request SendMessageToGlobeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SendMessageToGlobeResponse
 */
async function sendMessageToGlobeWithOptions(request: SendMessageToGlobeRequest, runtime: Util.RuntimeOptions): SendMessageToGlobeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.channelId)) {
    query['ChannelId'] = request.channelId;
  }
  if (!Util.isUnset(request.from)) {
    query['From'] = request.from;
  }
  if (!Util.isUnset(request.message)) {
    query['Message'] = request.message;
  }
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  if (!Util.isUnset(request.validityPeriod)) {
    query['ValidityPeriod'] = request.validityPeriod;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SendMessageToGlobe',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Sends a message to regions outside the Chinese mainland.
 *
 * @description ### [](#)Usage notes
 * The SendMessageToGlobe API operation does not support message delivery to the Chinese mainland.
 * ### [](#qps-)QPS limit
 * You can call this operation up to 30 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
 *
 * @param request SendMessageToGlobeRequest
 * @return SendMessageToGlobeResponse
 */
async function sendMessageToGlobe(request: SendMessageToGlobeRequest): SendMessageToGlobeResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendMessageToGlobeWithOptions(request, runtime);
}

model SendMessageWithTemplateRequest {
  channelId?: string(name='ChannelId', description='The ID of the channel.', example='5739'),
  from?: string(name='From', description='The signature. To query the signature, log on to the [Short Message Service (SMS) console](https://sms-intl.console.aliyun.com/overview) and navigate to the **Signatures** tab of the **Go China** page.

This parameter is required.', example='Alicloud321'),
  smsUpExtendCode?: string(name='SmsUpExtendCode', description='The extension code of the MO message.', example='90999'),
  templateCode?: string(name='TemplateCode', description='The code of the message template. To query the code, log on to the [SMS console](https://sms-intl.console.aliyun.com/overview) and navigate to the **Templates** tab of the **Go China** page.

This parameter is required.', example='SMS_****'),
  templateParam?: string(name='TemplateParam', description='The value of the variable in the message template. If a variable exists in the template, the parameter is required.', example='{"code":"1234","product":"ytx"}'),
  to?: string(name='To', description='The mobile phone number to which the message is sent. You must add the country code to the beginning of the mobile phone number. Example: 861503871\\\\*\\\\*\\\\*\\\\*.

For more information, see [Dialing codes](https://www.alibabacloud.com/help/en/sms/product-overview/dialing-codes?spm=a2c63.p38356.0.0.367279cbwQFoeM).

This parameter is required.', example='861503871****'),
  validityPeriod?: long(name='ValidityPeriod', description='The validity period of the message.', example='1'),
}

model SendMessageWithTemplateResponseBody = {
  messageId?: string(name='MessageId', description='The ID of the message.', example='1**************3'),
  numberDetail?: {
    carrier?: string(name='Carrier', description='The carrier that owns the mobile phone number.', example='China Mobile'),
    country?: string(name='Country', description='The country to which the mobile phone number belongs.', example='China'),
    region?: string(name='Region', description='The region to which the mobile phone number belongs.', example='Nanjing, Jiangsu'),
  }(name='NumberDetail', description='The details about the mobile phone number of the recipient.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8D23D6'),
  responseCode?: string(name='ResponseCode', description='The status code of the delivery request.', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the delivery request status.', example='The SMS Send Request was accepted'),
  segments?: string(name='Segments', description='The number of messages that incurred fees.', example='1'),
  to?: string(name='To', description='The mobile phone number to which the message was sent. The dialing code was added to the beginning of the mobile phone number. Example: 861503871\\\\*\\\\*\\\\*\\\\*.', example='861503871****'),
}

model SendMessageWithTemplateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SendMessageWithTemplateResponseBody(name='body'),
}

/**
 * @summary Sends a message to the Chinese mainland by using a message template.
 *
 * @description ### Usage notes
 * You can call the SendMessageWithTemplate operation to send messages only to the Chinese mainland.
 *
 * @param request SendMessageWithTemplateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SendMessageWithTemplateResponse
 */
async function sendMessageWithTemplateWithOptions(request: SendMessageWithTemplateRequest, runtime: Util.RuntimeOptions): SendMessageWithTemplateResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.channelId)) {
    query['ChannelId'] = request.channelId;
  }
  if (!Util.isUnset(request.from)) {
    query['From'] = request.from;
  }
  if (!Util.isUnset(request.smsUpExtendCode)) {
    query['SmsUpExtendCode'] = request.smsUpExtendCode;
  }
  if (!Util.isUnset(request.templateCode)) {
    query['TemplateCode'] = request.templateCode;
  }
  if (!Util.isUnset(request.templateParam)) {
    query['TemplateParam'] = request.templateParam;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  if (!Util.isUnset(request.validityPeriod)) {
    query['ValidityPeriod'] = request.validityPeriod;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SendMessageWithTemplate',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Sends a message to the Chinese mainland by using a message template.
 *
 * @description ### Usage notes
 * You can call the SendMessageWithTemplate operation to send messages only to the Chinese mainland.
 *
 * @param request SendMessageWithTemplateRequest
 * @return SendMessageWithTemplateResponse
 */
async function sendMessageWithTemplate(request: SendMessageWithTemplateRequest): SendMessageWithTemplateResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendMessageWithTemplateWithOptions(request, runtime);
}

model SmsConversionRequest {
  conversionTime?: long(name='ConversionTime', description='The time when the OTP message was delivered. The value is a UNIX timestamp. Unit: milliseconds.

*   If you leave the parameter empty, the current timestamp is specified by default.
*   If you specify the parameter, the timestamp must be greater than the message sending time and less than the current timestamp.', example='1349055900000'),
  delivered?: boolean(name='Delivered', description='Specifies whether customers replied to the OTP message. Valid values: true and false.

This parameter is required.', example='true'),
  messageId?: string(name='MessageId', description='The ID of the OTP message.', example='1008030300****'),
  to?: string(name='To'),
}

model SmsConversionResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='F655A8D5-B967-440B-8683-DAD6FF8D****'),
  responseCode?: string(name='ResponseCode', description='The status code. If OK is returned, the request is successful. For more information, see [Error codes](https://help.aliyun.com/document_detail/180674.html).', example='OK'),
  responseDescription?: string(name='ResponseDescription', description='The description of the status code.', example='OK'),
}

model SmsConversionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SmsConversionResponseBody(name='body'),
}

/**
 * @summary Delivers one-time password (OTP) message statuses to Alibaba Cloud, which calculates and monitors OTP conversion rates.
 *
 * @description Metrics:
 * *   Requested OTP messages
 * *   Verified OTP messages
 * An OTP conversion rate is calculated based on the following formula: OTP conversion rate = Number of verified OTP messages/Number of requested OTP messages.
 * > If you call the SmsConversion operation to query OTP conversion rates, your business may be affected. We recommend that you perform the following operations:
 * > * Call the SmsConversion operation in an asynchronous manner by configuring queues or events.
 * > * Manually degrade your services or use a circuit breaker to automatically degrade services.
 *
 * @param request SmsConversionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SmsConversionResponse
 */
async function smsConversionWithOptions(request: SmsConversionRequest, runtime: Util.RuntimeOptions): SmsConversionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.conversionTime)) {
    query['ConversionTime'] = request.conversionTime;
  }
  if (!Util.isUnset(request.delivered)) {
    query['Delivered'] = request.delivered;
  }
  if (!Util.isUnset(request.messageId)) {
    query['MessageId'] = request.messageId;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SmsConversion',
    version = '2018-05-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Delivers one-time password (OTP) message statuses to Alibaba Cloud, which calculates and monitors OTP conversion rates.
 *
 * @description Metrics:
 * *   Requested OTP messages
 * *   Verified OTP messages
 * An OTP conversion rate is calculated based on the following formula: OTP conversion rate = Number of verified OTP messages/Number of requested OTP messages.
 * > If you call the SmsConversion operation to query OTP conversion rates, your business may be affected. We recommend that you perform the following operations:
 * > * Call the SmsConversion operation in an asynchronous manner by configuring queues or events.
 * > * Manually degrade your services or use a circuit breaker to automatically degrade services.
 *
 * @param request SmsConversionRequest
 * @return SmsConversionResponse
 */
async function smsConversion(request: SmsConversionRequest): SmsConversionResponse {
  var runtime = new Util.RuntimeOptions{};
  return smsConversionWithOptions(request, runtime);
}

